<div class="full-screen">
<header>
    <div class="a-bar">
        <a href="javascript:history.back()" class="a-back">
		    <i class="arr left"></i>
            <{t}>返回<{/t}>
        </a>
		<span class="a-name"><{t}>推荐商品<{/t}></span>
        <div class="a-right">
        </div>
    </div>
</header>

<div class="full-padding"> 
<{if count($recommend_goods) > 0}>
    <form id="order-recommend-goods-form" action="<{link app=b2c ctl=wap_member act=do_recommend full=1}>" method="post">
	    <input type="hidden" name="obj_id" value="<{$obj_id}>">
        <span  id="opt-tab">
        <div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td colspan="4" style="padding-left:8px; padding-right:8px;">
                        <span class="recommend-confirm"><input name="" type="button" value="<{t}>确认<{/t}>" class="btn-recomok" style="background-color:gray;" onclick="javascript:(0);"></span>
                    </td>
                </tr>
                <tr>
                    <td width="10%">&nbsp;</td>
                    <td width="43%"><{t}>商品编号<{/t}></td>
                    <td width="25%"><{t}>采购价<{/t}></td>
                    <td width="22%"><{t}>库存<{/t}></td>
                </tr>
            </table>
        </div>
		</span>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <!--以下部分为一个循环-->
			<{foreach from=$recommend_goods item=item}>
			 <tbody class="body-recom">
				<tr>
					<td colspan="5" style="height:8px;"></td>
				</tr>
				<tr>
					<td colspan="2" style="padding-left:8px;"><input name="is_selected" type="radio" value="<{$item.goods_id}>" class="ck-grey"><b><{$item.products.0.bn}></b><!--{$item.name}--></td>
					<!--td><b><{$item.products.0.bn}></b></td-->
					<td><b><{$item.price*(1-$item.brand.rebate/100)|cur}></b></td>
					<td><b><{$item.products.0.store - $item.products.0.freez}></b></td>
				</tr>
			</tbody>
			<tr>
				<td colspan="4" style="height:8px;background:#ebebeb;"></td>
			</tr>
			</tbody>
			<{/foreach}>
		</table>
	</form>
<{else}>
    <{t}>暂无数据<{/t}>
<{/if}>
</div>
</div>

<script>
(function(){
	//悬浮框
    $(window).scroll(function(e){
		if($(this).scrollTop() > 60){
			ul = '<div style="position:fixed;top:0;left:0; width:94%; padding:6px 3% 0 3%; background:#fff;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="4" style="padding-left:8px; padding-right:8px;"><span class="recommend-confirm"><input name="" type="button" value="<{t}>确认<{/t}>" class="btn-recomok" style="background-color:gray;" onclick="javascript:(0);"></span></td></tr><tr><td width="10%">&nbsp;</td><td width="43%"><{t}>商品编号<{/t}></td><td width="25%"><{t}>采购价<{/t}></td><td width="22%"><{t}>库存<{/t}></td></tr></table></div>';
			$('#opt-tab').html(ul);
			but_change();
		}else{
			ul = '<div><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="4" style="padding-left:8px; padding-right:8px;"><span class="recommend-confirm"><input name="" type="button" value="<{t}>确认<{/t}>" class="btn-recomok" style="background-color:gray;" onclick="javascript:(0);"></span></td></tr><tr><td width="10%">&nbsp;</td><td width="43%"><{t}>商品编号<{/t}></td><td width="25%"><{t}>采购价<{/t}></td><td width="22%"><{t}>库存<{/t}></td></tr></table></div>';
			$('#opt-tab').html(ul);
            but_change();
		}
    });
})();

function but_change(){
    if(show().length == 0){
		no_selected();
	}else{
		has_selected();
	}
}

//没有选择商品时，按钮为灰色
$('#order-recommend-goods-form .ck-grey').on('click',function(event){
	if(show().length == 0){
		no_selected();
	}else{
		has_selected();
	}
});

//选中商品的状态为黄色
function has_selected(){
	ul = '<input type="submit" name="" type="submit" value="<{t}>确认<{/t}>" class="btn-recomok">';
	$('#order-recommend-goods-form .recommend-confirm').html(ul);
}

//不选中时为灰色
function no_selected(){
	ul = '<input name="" type="button" value="<{t}>确认<{/t}>" class="btn-recomok" style="background-color:gray;" onclick="javascript:(0);">';
	$('#order-recommend-goods-form .recommend-confirm').html(ul);
}

//获取选中商品
function show(){
	var cSelected = document.getElementsByName("is_selected");
	var idents = new Array();
	for(i = 0;i < cSelected.length;i++){
		if(cSelected[i].checked){
			idents.push(cSelected[i].checked);
		}
	}
	return idents;
}
</script>